# -*- coding:utf-8 -*-
import sys
import os
from os import path


def find_file_name(file_name,path_dir,result):
	subs=os.listdir(path_dir)
	for sub in subs:
		current_path=path.join(path_dir,sub)
		if sub.find(file_name)>-1:
			result.append(current_path)
		if path.isdir(current_path):
			try:
				find_file_name(file_name,current_path,result)
			except:
				print "find file '%s' from '%s' error" % (file_name,current_path)


if __name__ == "__main__":
	for i in range(len(sys.argv)):
		print "the argv %d is [%s]" % (i,sys.argv[i])

	path_name=sys.argv[1]

	if len(sys.argv)==3:
		path_dir=sys.argv[2]
	else:
		path_dir=path.dirname(sys.argv[0])

	path_dir=path.realpath(path_dir)
	print "find file ["+path_name+"] from path_dir ["+path_dir+"]"
	results=[]
	find_file_name(path_name,path_dir,results)
	for res in results:
		print res